home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CLASSSRC.PAK / REGLINK.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  1KB  |  47 lines

  1. //----------------------------------------------------------------------------
  2. // Borland WinSys Library
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.7  $
  6. //
  7. //----------------------------------------------------------------------------
  8. #include <winsys/pch.h>
  9. #include <winsys/registry.h>
  10. #include <string.h>
  11.  
  12. //
  13. // Construct a reglink pointing to a reglist, and add to end of list
  14. //
  15. TRegLink::TRegLink(TRegList& regList, TRegLink*& head)
  16. :
  17.   RegList(®List),
  18.   Next(0)
  19. {
  20.   AddLink(head, *this);
  21. }
  22.  
  23. //
  24. // Add a new link to the end of the link list
  25. //
  26. void TRegLink::AddLink(TRegLink*& head, TRegLink& newLink)
  27. {
  28.   TRegLink** link = &head;
  29.   while (*link)                 // put new link at end of list
  30.     link = &(*link)->Next;
  31.   *link = &newLink;
  32. }
  33.  
  34. //
  35. // Remove a link from the link list. Return true if link found & removed
  36. //
  37. bool TRegLink::RemoveLink(TRegLink*& head, TRegLink& remLink)
  38. {
  39.   for (TRegLink** link = &head; *link; link = &(*link)->Next) {
  40.     if (*link == &remLink) {
  41.       *link = (*link)->Next;     // remove from list
  42.       return true;
  43.     }
  44.   }
  45.   return false;
  46. }
  47.